var searchLock = false;
function searchLogin(){
	if(searchLock==false){
		searchLock = true ;
		$("#spLoadData").css("display","inline-block");
		var login = $("#idLogin").val();
		$.post(
				"ajax/index.jsp", 
				{
					"action":"login_search",
					"login":login
				},
				function(data) {
					if(data.status=='ok'){
						if(data.userlogin == "used"){
							$("#spLoginInfo").css("color","#FF0000");
						}
						if(data.userlogin == "free"){
							$("#spLoginInfo").css("color","#00FF00");
						}
						$("#spLoginInfo").html(data.userlogin);
						$("#spLoginInfo").css("display","inline-block");
						$("#spLoadData").css("display","none");
						
					}else{
                                            if(data.status == 'error')
                                                {
                                                    $("#spLoginInfo").html("Пустая строка");
                                                    $("#spLoadData").css("display","none");
                                                }
                                        }
				},"json"
			);
		searchLock=false;
	}
}


//////////

function searchEmail(){
	if(searchLock==false){
		searchLock = true ;
		$("#spLoadData").css("display","inline-block");
		var email = $("#idEmail").val();
		$.post(
				"ajax/index.jsp", 
				{
					"action":"email_search",
					"email":email
				},
				function(data) {
					if(data.status=='ok'){
						if(data.userEmail == "used"){
							$("#spEmailInfo").css("color","#FF0000");
						}
						if(data.userEmail == "free"){
							$("#spEmailInfo").css("color","#00FF00");
						}
						$("#spEmailInfo").html(data.userEmail);
						$("#spEmailInfo").css("display","inline-block");
						$("#spLoadData").css("display","none");
						
					}else{
                                            if(data.status == 'error')
                                                {
                                                    $("#spEmailInfo").html("Пустая строка");
                                                    $("#spLoadData").css("display","none");
                                                }
                                        }
				},"json"
			);
		searchLock=false;
	}
}
